home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CICA 1993 April
/
CICA MS Windows - April 1993.iso
/
unzipped
/
programr
/
vbasic
/
clpsib
/
clipsib.frm
(
.txt
)
next >
Wrap
Visual Basic Form
|
1991-11-03
|
21KB
|
444 lines
Form1
0Run This Program As An EXE File For Best Results
Form1
Label2
"Use Lists To Build A Shopping List
PyramidPic
WindowPic
ChessPic
ChessHelpCmdBut
PastryList
FruitList
VegList
PyramidPic
MeatList
PyramidPic
Label1
Shopping List
FindPic
FindTitle
FindTextBox
Label3
Find What:
Check1
Case Sensitive
Check2
Whole Word
Command1
Command2
Cancel
ShoppingList
Label4
%Drag FIND Box Around By Its Title Bar
ControlhWnd
BringWindowToTop
hWndG
SetWindowPos
hWndInsertAfter
wFlags
GetNextWindow
wFlagX
IsWindowVisiblex
GetActiveWindow
GetParent
SetParentC
hWndChild2
hWndNewParent
GetWindowLong
nIndex
SetWindowLong
dwNewLong
WS_CLIPSIBLINGS
SWP_NOSIZE
SWP_NOMOVE
SWP_NOZORDER
SWP_NOREDRAW
SWP_NOACTIVATE
SWP_DRAWFRAME
SWP_SHOWWINDOWi
SWP_HIDEWINDOW
SWP_NOCOPYBITSd
SWP_NOREPOSITIONK
GW_HWNDLAST
GW_HWNDNEXT
GW_HWNDPREV
GWL_WNDPROC
GWW_HINSTANCEj
GWW_HWNDPARENT
GWW_ID
GWL_STYLE
GWL_EXSTYLE
Truez
Falseq
XStart
YStart'
OKToMove1)
OKToMove2
OKToMove3
OKToMove4y
OKToMove6
WindowStack
NumOfControls
hWndWindowToMoveo
NeedsFixing
GW_HWNDFIRST
GW_OWNER
GW_CHILDl
SetClipSibling
Parentv
GetWindow
SetClipSiblingBit
Style
WS_CLIPSIBLING
Form_Clickw
Form_Loadf
Form1
Screen4
Width
Height~
GetWindowsDirectoryV
lpBuffer
nSize
WinDir
ChessBmp
OF_EXIST
OpenFile/
lpFileName
lpReOpenBuff
OFSTRUCT
wStyle
Buffer
ChessPicH
Picture
MousePointer
ChessPic_Click
ChessPic_MouseDownV
Button
Shift
OkToMoveChessPic
ChessPic_MouseMove
ChessHelpCmdBut
Visible
FormParenti
ControlParent
ParentType
AnyControl
NestedSibling
SetClipSiblingBits^
hWndParentj
WindowPic
Picture2_Click
Picture2_MouseDownE
OkToMovePicture2
Picture2_MouseMove
Picture2
Command1
WindowPic_Click
ChessHelpCmdBut_Click
List1_Click?
VegList
MeatListz
FruitList
PastryList
TopListBoxU
PrecedingListBox
MeatList_Click
MeatList_GotFocus
FruitList_Click0
FruitList_GotFocus
PastryList_Click
VegList_Click
VegList_GotFocus
FillLists
PastryList_GotFocus
ClickedToGetFocus
ShoppingList
ListIndex
BringToTop
ThisList
InsertAfter
ClickedToSetFocus
OkToMoveWindowPic
GetWindowNext
PyramidBmp:
PyramidPic
Pyramid
PyramidPic_Click
Index
PyramidPic_MouseDown
Pic4'
OkToMovePyramidPicQ
PyramidPic_MouseMove
Label3_Click\
FindLabel_Clicko
FindLabel_MouseDown
OkToMoveFindPic
FindLabel_MouseMove
FindPic
FindTitle_Click
FindTitle_MouseDown
FindTitle_MouseMove
Timer1_Timer
hwndFindPic
Timer1
Enabled
Purpose
program
demonstrate
Command1_Click
CLPSIB.BAS Rev. 1.0
Keith Funk (CIS 72240, 2020)7
Nov. 3, 1991
Many thanks to Daniel Appleman (Desaware) for explainingg
the Win3 WS_CLIPSIBLINGS style without which this program
could not have been written. I'd also like to thank
Ted Young and Jonathan Zuk for the help they have given
me in learning the Win3 API.o
The purpose of the program is to demonstrate how to
implement overlapping controls in a VB program.
NOTE that the Form and all controls have their ScaleMode sett
to PIXELS. Also, AutoRedraw is False for all controls. Thee
Picture Controls that contain the bitmaps PYRAMID.BMP
and CHESS.BMP have AutoSize set to True. No other control
properties have any particular relevance for this demo.
The program is FREEWARE. Feel free to use any part of
it in your own programs. Feedback and comments wouldd
be appreciated. Have fun.
-- Declarations for external functions.
CTLHWND.DLL is a custom DLL written by Jonathan Zuk. It
is included, with thanks to Jonathan, as part of CLPSIB.
ctlhwnd.dll
KernelZ
Kernel
-- Window style.
-- THE SECRET TO SUCCESS<g>a
-- SetWindowPos Flags
-- GetWindow() Constants
-- Window field offsets for GetWindowLong() and GetWindowWord()e
-- OpenFile action..
-- The mouse location when the mouse button is initially pressed.C
-- Flags to indicate when a picture can be moved. A move
is not allowed while a DoEvents is in progress.
-- Keeps track of the location of the list boxes in them
window stack.
-- Flag to determine if user clicked a listbox to make
a selection or just to bring it to the front.
SetClipSiblingBit
This routine sets the WS_CLIPSIBLINGS style bit for
all child windows of the Parent window *and* anyi
child windows of the child windows. The routine iss
recursive..
*** THIS IS THE KEY ROUTINE OF THE PROGRAM. ***
Setting the WS_CLIPSIBLINGS style bit is all that is-
needed to make VB work properly with overlappingg
controls. Or at least, so it appears to me.
-- Get the first child window.
-- Set the CLIPSIBLING bit for each child window.n
Loop terminates when GetWindowNext runs out ofu
child windows and returns NULL.
-- Get current style.y
-- Set the bit.e
-- Set new style.,
-- Process any child windows of this window.
-- recursive call.
-- Get the next top level child window.y
Form_Load
-- Display hourglass mousepointer.
-- Show the window centered on the screen.
* THIS IS THE KEY TO THE ENTIRE DEMO. TRY COMMENTING OUT
* THE CALL TO SetClipSiblings AND WATCH THE PROGRAM FALL TO PIECES.*
D* **
-- Set the CLIPSIBLING Style bit for all child windows.d
SET UP THE CHESS.BMP CONTROLS.R
-- Find the Win3 directory and append a backslash.
Can't Find Window's Directory"
Fatal Error"
-- Strip trailing \0.
-- If CHESS.BMP exists, load it into ChessPic.
CHESS.BMP"
Sorry, This Program Requires The Win3 Bitmap CHESS.BMP."
FATAL ERROR"
-- Put the Command Button for CHESS.BMP on top of the
Chess Picture, so the picture can be scrolled
underneath it.
-- If PYRAMID.BMP exists, load it into the three PyramidPic controls.A
PYRAMID.BMP"
Sorry, This Program Requires The Win3 Bitmap PYRAMID.BMP."
FATAL ERROR"
-- Make sure the PyramidPics are higher in the window stack than
WindowPic so they will appear on top of CHESS.BMP.-
-- Display the Chess demo controls.W
SET UP THE LIST BOX CONTROLS.
-- Add items to the lists.
-- Place the controls in their correct order.
Meat, Veg, Fruit then Pastry.
-- Display them.
-- improves the way Win3 initially paints the display.
-- Set Global variables to keep track of which listbox
is on top and which list it normally comes after.
SET UP THE FIND CONTROLS.
-- Make the Find "dialog box" the top most child
window of the Form, so it is *always* displayed on top of
all other child windows. Then make it visible.i
-- improves the way Win3 initally paints the screen.
-- Set standard mousepointer.n
ChessPic_MouseDown
This control is filled with the bitmap CHESS.BMPP
during the Form1_Load Event. Because its AutoSize
Property is set to True, it becomes much larger thann
the WindowPic control on which it is placed, but youu
can only see the area of CHESS.BMP that is within
the boundaries of WindowPic. However, you can use yourr
mouse to -move- different parts of CHESS.BMP into the
visible area. NOTE how the picture -slides under- the
Help Command Button. Too neat.<g>
This is where the moving of CHESS.BMP begins. It is
continued in the MouseMove Event.
-- Save mouse X/Y so MouseMove can determine how far
the mouse has moved.o
-- Set flag for MouseMove.
ChessPic_MouseMove
This is the routine that actually moves CHESS.BMP..
Note that the flag OkToMoveChessPic and the DoEventss
are *absolutely* essential to the correct operation
of this routine..
-- Only move the picture if left button is down.
-- Only move the picture if no DoEvent is in progress.
-- DoEvents has finished.
WindowPic_Click
This control is the Parent of the ChessPic control.
That is, ChessPic has been placed *on* this control,,
*not* on Form1. It serves as a clipping window whichh
restricts the amount of ChessPic which is visible..
NOTE that ChessPic has its AutoSize Property set to
True, so when CHESS.BMP is loaded into its Picturee
Property, ChessPic becomes *much* larger than thiss
picture control..
ChessHelpCmdBut_Click
The main purpose of this control is to demonstratee
how setting the WS_CLIPSIBLINGS style bit allows youu
to slide a picture underneath another control. NOTE
that this control has been placed on the WindowPicc
control. It is *not* on Form1..
Use the LEFT Mouse Button to drag the small pictures on top of CHESS.BMP and to scroll CHESS.BMP."
Chess Help
MeatList_GotFocus
Displays this list on top of the other list boxes.-
FruitList_GotFocus
Displays this list on top of the other list boxes..
VegList_GotFocus
Displays this list on top of the other list boxes.-
FillLists
Fills the meat, vegetable, fruit and pastry lists with goodies.
-- Fill the Meat List.
Rib Roast"
Pork Chops
Chicken"
Ground Beef"
Lamb Chops
Spare Ribs
Pigs Feet"
Sausage"
Hot Dogs
-- Fill the Vegetable List.
Potatoes
Onions
Turnip
Carrots"
Beans"
Eggplant
Celery
-- Fill the Fruit List
Apples
Oranges"
Pears"
Grapes
Melons
Lemons
Limes"
Apricots
Quinces"
Plums"
Peaches"
-- Fill the Pastry List
Donuts
Bread"
Crullers
Cherry Pie
Lemon Cake
Cookies"
Macaroons"
Muffins"
Brownies
Date Squares
Peach Pie"
PastryList_GotFocus
Displays this list on top of the other list boxes.-
MeatList_Click
Adds the item selected from MeatList to the ShoppingList.
-- Don't do anything if user just clicked to bring
the list to the front.s
-- Add selected item to our shopping list.
FruitList_Click
Adds the item selected from FruitList to the ShoppingList..
-- Don't do anything if user just clicked to bring
the list to the front.r
-- Add selected item to our shopping list.
PastryList_Click
Adds the item selected from PastryList to the ShoppingList.
-- Don't do anything if user just clicked to bring
the list to the front.s
-- Add selected item to our shopping list.
VegList_Click
Adds the item selected from VegList to the ShoppingList.-
-- Don't do anything if user just clicked to bring
the list to the front.s
-- Add selected item to our shopping list.
BringToTop
This routine brings ThisList to the top of the window
stack so it appears on top of the other listboxes..
It also sets some global variables that keep track of
the current order of the window stack..
-- If ThisList is already at the top then there's nothing to do.
-- Put the listbox that is currently on top back in its proper location.
Note that we don't need to specify x,y,cx and cy because the flagsf
SWP_NOMOVE and SWP_NOSIZE tell Win3 to ignore these values.
-- Find out which window precedes ThisList in the window stack.t
-- Move this listbox to the front of the group ofu
listboxes *BUT* behind the FindPic control. We aree
demonstrating how a control (FindPic) can *always*w
remain in front of all other controls even when
these controls are being re-arranged.
-- Tell Click Event to ignore this click because
user is just bringing the list to the front.e
PyramidPic_MouseDown
This is where the start of moving the small picture controls containing
PYRAMID.BMP begins.
-- Save mouse X/Y so MouseMove can determine how far
the mouse has moved.u
-- Set flag for MouseMove.
PyramidPic_MouseMove
This is the routine that actually moves the picture controls that
contain PYRAMID.BMP..
-- Only move the picture if the left mouse button is down.
-- Only move the picture if no DoEvent is in progress.
-- DoEvents has finished.
FindTitle_MouseDown
This Picture Control acts as a dark blue title bar for the FindPicc
Picture Control. Its purpose is to allow FindPic and all its childd
windows to be dragged around the Form..
NOTE: That FindPic *always* appears on top of any other control..
Very desireable for a Find Dialog Box..
-- Save mouse X/Y so MouseMove can determine how far
the mouse has moved.u
-- Set flag for MouseMove.
FindTitle_MouseMove
This is the routine that actually drags FindPic around.
-- Only move the picture if left button is down.
-- Only move the picture if no DoEvent is in progress.
-- DoEvents has finished.
Command1_Click
In a -real- program, this button would activate the
code to find text..
You Actually Expected Something To Happen?<g>"